/*
 * 文件名：LocalCarTypeForIndexController.java	 
 * 时     间：下午6:39:42
 * 作     者：Administrator       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.local.controller.index;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.local.model.LocalCarType;
import com.local.model.LocalChargeBytimeType;
import com.local.page.LocalCarTypePageInfo;
import com.local.page.LocalChargeByTimeTypePageInfo;
import com.local.service.face.LocalCarTypeService;
import com.local.service.face.LocalChargeByTimeTypeService;
import com.qianhai.common.constants.CommonContans;
import com.qianhai.common.controller.BaseController;

/**
 * 类描述: 车辆类型管理，如大车、小车、军车、警车、摩托车等。(并非车辆收费类型)。次类保证给页面显示列表显示.
 * 
 * @ClassName: LocalCarTypeForIndexController
 * @author Administrator
 * @date 2016年4月17日 下午6:39:42
 */
@RestController
@RequestMapping(value = "/index/carType", method = RequestMethod.POST)
public class LocalCarTypeForIndexController extends BaseController
{
	@Autowired
	private LocalCarTypeService carTypeService;
	
	@Autowired
	private LocalChargeByTimeTypeService localChargeByTimeTypeService;
	
	/**
	 * 
	 * 方法描述： 获取所有车辆类型
	 * 
	 * @Title: queryAllBypage
	 * @param @param pageInfo
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2016年4月17日
	 * @throws
	 */
	@RequestMapping(value = "/queryAllBypage.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryAllBypage(@RequestBody LocalCarTypePageInfo pageInfo)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			carTypeService.queryByPage(pageInfo);
			resultMap.put(CommonContans.STRUTS_DATA, pageInfo);
			resultMap.put("curTime", System.currentTimeMillis());
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：查询所有的计费规则类型
	 * @Title: queryAllChargeType 
	 * @param @param pageInfo
	 * @param @return
	 * @return ModelMap
	 * @user Administrator
	 * 2016年5月19日
	 * @throws
	 */
	@RequestMapping(value = "/queryAllChargeType.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryAllChargeType(@RequestBody LocalChargeByTimeTypePageInfo pageInfo)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			localChargeByTimeTypeService.queryByPage(pageInfo);
			resultMap.put(CommonContans.STRUTS_DATA, pageInfo);
			resultMap.put("curTime", System.currentTimeMillis());
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：添加or更新车型
	 * @Title: addCarOrModifyType 
	 * @param @param localCarType
	 * @param @return
	 * @return ModelMap
	 * @user Administrator
	 * 2016年4月19日
	 * @throws
	 */
	@RequestMapping(value = "/addCarOrModifyType.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap addCarOrModifyType(@RequestBody LocalCarType localCarType)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			carTypeService.addCarType(localCarType);
			resultMap.put(CommonContans.STRUTS_RESULT,CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/addCarOrModifyTypeRules.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap addCarOrModifyTypeRules(@RequestBody LocalChargeBytimeType localChargeBytimeType)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			localChargeByTimeTypeService.addCarType(localChargeBytimeType);
			resultMap.put(CommonContans.STRUTS_RESULT,CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：通过车类型查找车类型具体信息
	 * @Title: queryByUuid 
	 * @param @param localCarType
	 * @param @return
	 * @return ModelMap
	 * @user Administrator
	 * 2016年4月19日
	 * @throws
	 */
	@RequestMapping(value = "/queryByUuid.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryByUuid(@RequestBody LocalCarType localCarType)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_DATA, carTypeService.queryByUuid(localCarType));
			resultMap.put(CommonContans.STRUTS_RESULT,CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/queryByUuidRules.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryByUuidRules(@RequestBody LocalChargeBytimeType localChargeBytimeType)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_DATA, localChargeByTimeTypeService.queryByUuid(localChargeBytimeType));
			resultMap.put(CommonContans.STRUTS_RESULT,CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：通过主键删除车类型
	 * @Title: deleteCarType 
	 * @param @param localCarType
	 * @param @return
	 * @return ModelMap
	 * @user Administrator
	 * 2016年4月19日
	 * @throws
	 */
	@RequestMapping(value = "/deleteCarType.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap deleteCarType(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_DATA, carTypeService.deleteByPrimaryKey(uuid));
			resultMap.put(CommonContans.STRUTS_RESULT,CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/deleteCarTypeRules.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap deleteCarTypeRules(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_DATA, localChargeByTimeTypeService.deleteByPrimaryKey(uuid));
			resultMap.put(CommonContans.STRUTS_RESULT,CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
}
